Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select connector type before name #11388

Merged
merged 5 commits into from
Mar 25, 2022
Merged

Select connector type before name #11388

merged 5 commits into from
Mar 25, 2022

Conversation

timroes
Copy link
Collaborator

@timroes timroes commented Mar 24, 2022

What

Closes #11261

This will pull the connector type before the name box (and hide the name input as long as no connector is selected). It will also cause the name to become the connector definition name by default when it's switched.

Peek.2022-03-24.12-18.mp4

@timroes timroes requested a review from jamakase March 24, 2022 11:19
@timroes timroes requested a review from a team as a code owner March 24, 2022 11:19
@github-actions github-actions bot added area/frontend area/platform issues related to the platform labels Mar 24, 2022
Copy link
Contributor

@jamakase jamakase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small proposal for change.

*/
const SetDefaultName: React.FC<{
availableConnectors: ConnectorDefinition[];
}> = ({ availableConnectors }) => {
Copy link
Contributor

@jamakase jamakase Mar 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing availableConnectors and searching - you could use useServiceForm hook that has selectedService prop.

So this method will shorten to something like

const { selectedService } = useServiceForm();
const [,,helpers] = useField("name");

useEffect(() => {
  const name = selectedService?.name ?? "";
  helpers.setValue(name);
}, [selectedService, helpers]);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will use useServiceForm here.

I tried using useField initially, but the problem is that the helpers it's returning isn't a stable reference, thus causing this useEffect to trigger in an endless loop, thus using the setFieldValue here instead (which is a stable reference).

@timroes timroes merged commit 55a87bf into master Mar 25, 2022
@timroes timroes deleted the tim/connector-form-order branch March 25, 2022 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changing the order of connector name and connector type select box
2 participants